<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        new Promise(r => {
            console.log(-2);
            r()
            console.log(-1);
        }).then(()=>{
            console.log('000')
            
            setTimeout(()=> {
                console.log(111)
            }, 0)
        }).then(()=>{
            console.log(222)
            const n1 = Date.now()

            while(Date.now() - n1 <  500){
                // console.log('waiting...')
            }
            console.log('after wait')

        })
    </script>
    <script>
         console.log(456)
        // const n1 = Date.now()
        // while(Date.now() - n1 < 3 * 1000){
        //     // console.log('waiting...')
        // }
    </script>
    <div style="width: 300px; height: 300px; background-color: red"></div>
    <img src="www" alt="" onerror="console.log('error')">
    <script>
        // console.log(789)
        window.addEventListener('DOMContentLoaded', () => {
            console.log('load')
        })
    </script>
</body>
</html>